package com.yh.mapper;


import com.yh.javabean.Users;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import java.util.List;
/**
 * @Auther: als
 * @Date: 2024/6/1 - 06 - 01 - 11:22
 * @Description: com.yh.mapper
 * @version: 1.0
 */
@Mapper
public interface UsersMapper {
    Users selectByUserName(String username);

    @Select("select * from users")
    @Results(id = "u_r",value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "id",property = "role",one=@One(select = "com.yh.dao.RoleDao.selectByUid",fetchType = FetchType.EAGER))
    }
    )
    List<Users> selectAll();

    int insertUsers(Users users);

    @Select("select * from users where id=#{id}")
    @ResultMap("u_r")
    Users selectById(int id);

    @Delete("delete from users where id=#{id}")
    int deleteById(int id);

    @Update("update users set email=#{email},username=#{username},password=#{password},phoneNum=#{phoneNum},status=#{status} where id=#{id}")
    int updateUsers(Users users);
}